package org.box.demos.multithreading.wgetmt.core;

/**
 * Represents significant values of the content type.
 * 
 * @author <a href="mailto:alexander.box@gmail.com">Alexander Korobka</a>
 * 
 */
public enum ContentType {
	TEXT_HTML("H"), NON_TEXT_HEML("B"), UNKNOWN("U");
	
	private final String shortVal;

	private ContentType(String shortVal) {
		this.shortVal = shortVal;
	}

	public static ContentType parse(String conentType) {
		return conentType.equalsIgnoreCase("text/html") ? TEXT_HTML
				: NON_TEXT_HEML;
	}

	public static ContentType parseShort(String shortVal) {
		for (ContentType ct : values()) {
			if (ct.shortVal.equals(shortVal)) 
				return ct;
		}
		return UNKNOWN;
	}
	
	public String shortVal() {
		return shortVal;
	}
}